<template>
    <!-- 页面头部 -->
    <HomePageHead></HomePageHead>
    <!-- 导航栏 -->
    <HomePageNavigation></HomePageNavigation>
    <!-- 公司信息详情页 -->
    <section class="index_main">
        <!-- 列表页广告一 -->
        <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
        <!-- 面包屑导航 -->
        <div class="breadcrumb phone_none">
            <div class="inner">
                <span class="location">当前位置：</span>
                <el-breadcrumb :separator-icon="ArrowRight">
                    <el-breadcrumb-item>
                        <NuxtLink to="/">首页</NuxtLink>
                    </el-breadcrumb-item>
                    <el-breadcrumb-item v-if="parent_name != ''">
                        <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
                    </el-breadcrumb-item>
                    <el-breadcrumb-item>
                        <NuxtLink :to="`list-1.html`"> {{ routeName }}</NuxtLink>
                    </el-breadcrumb-item>
                    <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
        </div>

        <div class="breadcrumb_box pc_none">
                        
                        <span class=" ">当前位置：</span>
                        <NuxtLink to="/">首页</NuxtLink>

                        <span class=" " v-if="parent_name !=''">&gt;</span>
                        <NuxtLink v-if="parent_name !=''" :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>

                        <span class=" " >&gt;</span>
                        <NuxtLink :to="`list-1.html`"> {{ routeName }}</NuxtLink>

                        <span class="" >&gt;</span>
                        <span class="" >{{ routeNewsTtitle }}</span>
                         
        </div>


        <!-- 面包屑  end-->
        <div class="info_head_box clearfix phone_none">
            <div class="info_head_left">
                <a class="info_head_a info_head_only" :title="公司信息">公司信息</a>
            </div>
        </div>

        <div class="phone_box_1 pc_none" >
            <div class="phone_box_1_head">
                <a class="" >公司信息</a>
            </div>
        </div>


        <section class="index_2 clearfix">

            <img class="index_2_img" :src="detailImg[0]" :title="routeNewsTtitle" alt="">
            <div class="index_2_right">
                <h4 class="index_2_h4"> {{ routeNewsTtitle }}</h4>
                <div class="index_2_title_box clearfix">
                    <time class="index_2_title">
                        成立日期：
                        <span v-if="time"> {{ time }}</span>
                    </time>
                    <span class="index_2_title">
                        所在城市：
                        <span v-if="newsDetail.city_name">{{ newsDetail.city_name }}</span>
                    </span>
                </div>
                <div class="index_2_ul clearfix phone_none">
                    <div class="index_2_ul_left">
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">机构性质</label>
                            <span class="index_2_li_text " v-if="newsDetail.jobnature_name">
                                {{ newsDetail.jobnature_name }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">负 责 人</label>
                            <span class="index_2_li_text" v-if="newsDetail.manager">
                                {{ newsDetail.manager }}
                            </span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">联 系 人</label>
                            <span class="index_2_li_text " v-if="newsDetail.content_person">
                                {{ newsDetail.content_person }}
                            </span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">联系电话</label>
                            <span class="index_2_li_text ">{{ newsDetail.telephone }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">手 &nbsp;&nbsp;&nbsp;&nbsp; 机</label>
                            <span class="index_2_li_text ">{{ newsDetail.mobile }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">地 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
                            <span class="index_2_li_text ">{{ newsDetail.adress }}</span>
                        </div>
                    </div>
                    <div class="index_2_ul_left">

                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">所属行业</label>
                            <span class="index_2_li_text ">{{ newsDetail.hy_name }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">联系QQ</label>
                            <span class="index_2_li_text ">{{ newsDetail.QQ }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">网 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
                            <span class="index_2_li_text ">{{ newsDetail.company_url }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">邮政编码</label>
                            <span class="index_2_li_text ">{{ newsDetail.post_code }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">传 &nbsp;&nbsp;&nbsp;&nbsp; 真</label>
                            <span class="index_2_li_text ">{{ newsDetail.fax }}</span>
                        </div>
                    </div>
                </div>

                <div class="index_2_ul clearfix pc_none">

                    <div class="index_2_ul_left">

                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">机构性质</label>
                            <span class="index_2_li_text " v-if="newsDetail.jobnature_name">
                                {{ newsDetail.jobnature_name }}</span>
                        </div>

                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">所属行业</label>
                            <span class="index_2_li_text ">{{ newsDetail.hy_name }}</span>
                        </div>

                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">负 责 人</label>
                            <span class="index_2_li_text" v-if="newsDetail.manager">
                                {{ newsDetail.manager }}
                            </span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">联 系 人</label>
                            <span class="index_2_li_text " v-if="newsDetail.content_person">
                                {{ newsDetail.content_person }}
                            </span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">联系电话</label>
                            <span class="index_2_li_text ">{{ newsDetail.telephone }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">手 &nbsp;&nbsp;&nbsp;&nbsp; 机</label>
                            <span class="index_2_li_text ">{{ newsDetail.mobile }}</span>
                        </div>
                        
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">联系QQ</label>
                            <span class="index_2_li_text ">{{ newsDetail.QQ }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">传 &nbsp;&nbsp;&nbsp;&nbsp; 真</label>
                            <span class="index_2_li_text ">{{ newsDetail.fax }}</span>
                        </div>
                        
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">邮政编码</label>
                            <span class="index_2_li_text ">{{ newsDetail.post_code }}</span>
                        </div>
                        
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">网 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
                            <span class="index_2_li_text ">{{ newsDetail.company_url }}</span>
                        </div>
                        <div class="index_2_li clearfix">
                            <label class="index_2_li_label">地 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
                            <span class="index_2_li_text ">{{ newsDetail.adress }}</span>
                        </div>
                    </div>

                </div>

            </div>
        </section>

        <section class="index_3 clearfix">

            <div class="info_2_head_box clearfix phone_none">
                <div class="info_2_head_left">
                    <a class="info_2_head_a info_2_head_only" title="">详情信息</a>
                </div>
            </div>

            <div class="phone_box_1 pc_none" >
                <div class="phone_box_1_head">
                    <a class="" >详情信息</a>
                </div>
            </div>

            <div class="info_article" v-html="newsDetail.content"></div>
        </section>
    </section>

    <!-- 列表页广告二 -->
    <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
    <!-- 页面底部 -->
    <HomeFoot1></HomeFoot1>

</template>


<script setup>
import { ref } from 'vue'
import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
import { ArrowRight } from '@element-plus/icons-vue'
//2.页面路径 start ---------------------------------------->
const route = useRoute();
const articleId = parseInt(route.params.id);
const targetSegment = getRoutePath(1);
const targetSegment1 = getRoutePath(2);

// 2.1 查询一级栏目的id
//通过导航路径反向查询导航id
let routeId;
const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'pinyin': targetSegment,
    },
});
if (getRouteId.code == 200) {
    routeId = getRouteId.data.category_id
} else {
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    console.log("错误位置：通过url路径查询导航池id")
    console.log("后端错误反馈：", getRouteId.message)
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}
// 2.2查询二级栏目的id及名称
let routeName = ref('');
let routeId1 = ref('');
const getRoutePName = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'pinyin': targetSegment + "/" + targetSegment1,
    },
});
if (getRoutePName.code == 200) {
    routeId1.value = getRoutePName.data.category_id;
    routeName.value = getRoutePName.data.alias;
} else {
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    console.log("错误位置：通过url路径查询导航池id")
    console.log("后端错误反馈：", getRouteId.message)
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}
//2.页面路径 end ---------------------------------------->

//3.面包屑 start ---------------------------------------->
const parent_name = ref("");
const parent_id = ref("");
const parent_pinyin = ref("");

let getParentNav = async () => {
    const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
        method: 'GET',
        query: {
            'catid': routeId
        },
    });

    if (listData.code == 200) {
        parent_name.value = listData.data.alias;
        parent_id.value = listData.data.parent_id;
        parent_pinyin.value = listData.data.aLIas_pinyin;

    } else {
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：获取面包屑导航")
        console.log("后端错误反馈：", listData.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
//获得父级栏目详情
getParentNav();
//3.面包屑 end ---------------------------------------->

//4.新闻详情 start ---------------------------------------->
//4.1 资讯详情
const newsDetail = ref({})
const routeNewsTtitle = ref("");
//4.2 发布日期
const time = ref("");
//4.3 路径
const routLevelTitle = ref("");
const routLevelId = ref("");
//4.4 是否展示投票
const articleChoice = ref(false);
let detailImg = ref('');
let seoTitle;
let seoDescription;
let seoKeywords;
//4.5 获取详情
const mkdata = await requestDataPromise('/web/getWebsiteCompanyInfo', {
    method: 'GET',
    query: {
        'id': articleId
    },
});
if (mkdata.code == 200) {
    //获取内容
    newsDetail.value = mkdata.data;
    detailImg.value = JSON.parse(mkdata.data.imgurl);
    //修正标题长度
    if (newsDetail.value.title.length >= 20) {
        routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
    } else {
        routeNewsTtitle.value = newsDetail.value.title
    }
    //获取发布时间
    if (newsDetail.value.data) {
        time.value = newsDetail.value.data.split(' ')[0];
    }
    seoTitle = newsDetail.value.title;
    seoDescription = newsDetail.value.description;
    seoKeywords = newsDetail.value.keyword;
} else {
    // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    // console.log("错误位置：获取详情内容")
    // console.log("后端错误反馈：", mkdata.message)
    // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}
//4.新闻详情 end ---------------------------------------->

//5.设置seo信息 start---------------------------------------->

const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
    method: 'GET',
    query: {
        'catid': routeId1.value
    },
});

if (setData.code == 200) {
    let seoSuffix = setData.data.suffix;
    let seoName = setData.data.website_name;

    useSeoMeta({
        title: seoTitle + "_" + seoName + "_" + seoSuffix,
        meta: [
            { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
            { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
            { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
        ]
    });
} else {
    console.log("设置频道页SEO出错！", setData.message)
}
//5.设置seo信息 end---------------------------------------->

//6.广告 start ---------------------------------------->
let adImg1 = ref([]);
let adImg2 = ref([]);
onMounted(async () => {
    const { $webUrl, $CwebUrl } = useNuxtApp();
    //广告1
    let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_detail_0001`
    const responseAd1 = await fetch(url, {
        headers: {
            'Content-Type': 'application/json',
            'Userurl': $CwebUrl,
            'Origin': $CwebUrl
        }
    });
    const resultAd1 = await responseAd1.json();
    adImg1.value = resultAd1.data[0];

    //广告2
    let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_detail_0002`
    const responseAd2 = await fetch(url2, {
        headers: {
            'Content-Type': 'application/json',
            'Userurl': $CwebUrl,
            'Origin': $CwebUrl
        }
    });
    const resultAd2 = await responseAd2.json();
    adImg2.value = resultAd2.data[0];
})
//6.广告 end ---------------------------------------->
</script>

<style lang="less" scoped>
@import url(@/assets/css/peixun/detail.less);
</style>

<style lang="less" scoped>

 
    @media screen and (min-width:801px){/*pc*/
         
            .page_pc_none {
                display: none !important;
            }
            .pc_none{display:none;}
    }
    @media screen and (max-width:800px){/*ipad_phone*/
        .index_main{width:100%;margin:0px auto 30px;}

        .breadcrumb_box {

            height: 22px;
            width: 92%;
            margin: 10px auto;
            word-break: keep-all;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
            color: #666;
            * {
                font-size: 14px;
                display: inline;
                color: #666;
                line-height: 22px;
                height: 22px;
                margin-right: 5px;
            }
        }
        
        .phone_box_1{
                                            
                width:92%;margin:0px auto 0px;    
                .phone_box_1_head{

                    height:50px;line-height:50px;
                    background:#fff;border-bottom:1px solid #E6E6E6;
                     width:100%;
                    
                    a{ 
                            float:left;height:50px;line-height:50px;margin:0;position:relative;
                            color:#489d97;font-size:18px; font-weight:bold;box-sizing:border-box;
                            position:relative;padding-left:8px;
                    }

                    a::before{
                        content: '';display: block;
                        position:absolute;left:0px;top:18px;
                        background: linear-gradient(to top, #0998A9, #6ADDD6);
                        width:3px;height:15px;
                    }

                }
                    
                    

        }
        
        .phone_box_2{
                                            
                width:92%;margin:0px auto 0px;    
                .phone_box_1_head{

                    height:50px;line-height:50px;
                    background:#fff;border-bottom:1px solid #E6E6E6;
                     width:100%;
                    
                    a{ 
                            float:left;height:50px;line-height:50px;margin:0;position:relative;
                            color:#489d97;font-size:18px; font-weight:bold;box-sizing:border-box;
                            position:relative;padding-left:8px;
                    }

                    a::before{
                        content: '';display: block;
                        position:absolute;left:0px;top:18px;
                        background: linear-gradient(to top, #0998A9, #6ADDD6);
                        width:3px;height:15px;
                    }

                }
                    
                    

        }

        .index_2{width:100%;margin:10px auto 0px;}
         
        .index_2_img{max-width:92%;height:302px;width:auto;
            margin:0px auto 0px;float:none;display:block;border-radius:8px;}

         .index_2_right{width:92%;float:none;margin:0px auto;}   

         .index_2_h4{font-size:16px;color:#333;line-height:26px; padding:0;border:0px;
                            white-space:unset;word-break:unset;margin-top:11px;
         }
         .index_2_title{font-size:14px;margin-right:10px;}

            .index_2_ul{ height:auto;}
            .index_2_li{margin-bottom:20px;width:49%;}
            .index_2_li:nth-of-type(odd){float:left;}
            .index_2_li:nth-of-type(even){float:right;}
            .index_2_li:nth-last-of-type(1){width:100%; } 
            .index_2_li:nth-last-of-type(2){width:100%; } 

            .index_2_li:nth-of-type(1){width:100%; } 
            .index_2_li:nth-of-type(2){width:100%; } 

             
            .index_2_li .index_2_li_label{line-height:18px;height:18px;font-size:14px;min-width:auto;margin-right:8px;}
            .index_2_li .index_2_li_text{
                line-height:18px;font-size:14px;flex:1;
                        
                        word-wrap: break-word;
                        overflow-wrap: break-word;
                        white-space: pre-wrap;
                        word-break: break-all;
            }

            .index_2_ul .index_2_ul_left{width:100%;overflow:hidden;float:none;}

             .info_article{ font-size:16px!important;line-height:26px!important;margin:15px auto 0!important;width:92%!important;}
             .info_article::v-deep *{ font-size:16px!important;line-height:26px!important; }


        .page_phone_none {
                    display: none !important;
        }
        .phone_none{display:none;}
    }
</style>


